#include <iostream>
#include <math.h>
#include <string.h>
#define int long long
using namespace std;


struct group{
	int num,cost;
};

long long dp[10+1][1000000+1];

signed main(){
	int n,m,ans=0x7fffffff;
	cin>>n>>m;
	group a[n];
	int sum=0;
	for(int i=0;i<n;i++)
		cin>>a[i].num;
	for(int i=0;i<n;i++){
		cin>>a[i].cost;
		sum += a[i].cost*a[i].num;
	}
	memset(dp,0,sizeof(dp));
	for(int i=0;i<=sum;i++)
		dp[0][i] = 1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=sum;j++)
			for(int k=0;k<=min(j/a[i-1].cost,a[i-1].num);k++)
				ans = (dp[i][j] = k==0?dp[i-1][j]:max(dp[i-1][j-a[i-1].cost*k]*k,dp[i-1][j]))>=m?min(ans,j):ans;
//	for(int i=0;i<=n;i++){
//		for(int j=0;j<=m;j++)
//			cout<<(dp[i][j]==0x7fffffff?-1:dp[i][j])<<" ";
//		cout<<endl;
//	}
	cout<<ans;
	return 0;
}
